package com.linkoog.devtools.code_generator.database.domain;

/**
 * @author xiaoyu
 */
public class ConnectionInfo {
    private String name;
    private String description;

    private DbType dbType;
    private String host;
    private Integer port;
    private String username;
    private String passwd;
    private String database;
    private String schema;

    public ConnectionInfo() {
    }

    public ConnectionInfo(DbType dbType, String name, String description, String host, Integer port, String username, String password, String database, String schema) {
        this.dbType = dbType;
        this.name = name;
        this.description = description;
        this.host = host;
        this.port = port;
        this.username = username;
        this.passwd = password;
        this.database = database;
        this.schema = schema;
    }

    public DbType getDbType() {
        return dbType;
    }

    public ConnectionInfo setDbType(DbType dbType) {
        this.dbType = dbType;
        return this;
    }

    public String getName() {
        return name;
    }

    public ConnectionInfo setName(String name) {
        this.name = name;
        return this;
    }

    public String getDescription() {
        return description;
    }

    public ConnectionInfo setDescription(String description) {
        this.description = description;
        return this;
    }

    public String getHost() {
        return host;
    }

    public ConnectionInfo setHost(String host) {
        this.host = host;
        return this;
    }

    public Integer getPort() {
        return port;
    }

    public ConnectionInfo setPort(Integer port) {
        this.port = port;
        return this;
    }

    public String getUsername() {
        return username;
    }

    public ConnectionInfo setUsername(String username) {
        this.username = username;
        return this;
    }

    public String getPasswd() {
        return passwd;
    }

    public ConnectionInfo setPasswd(String passwd) {
        this.passwd = passwd;
        return this;
    }

    public String getDatabase() {
        return database;
    }

    public ConnectionInfo setDatabase(String database) {
        this.database = database;
        return this;
    }

    public String getSchema() {
        return schema;
    }

    public ConnectionInfo setSchema(String schema) {
        this.schema = schema;
        return this;
    }

    @Override
    public boolean equals(Object o) {
        if (this == o) return true;
        if (o == null || getClass() != o.getClass()) return false;

        ConnectionInfo that = (ConnectionInfo) o;

        if (dbType != that.dbType) return false;
        if (name != null ? !name.equals(that.name) : that.name != null) return false;
        if (host != null ? !host.equals(that.host) : that.host != null) return false;
        if (port != null ? !port.equals(that.port) : that.port != null) return false;
        if (username != null ? !username.equals(that.username) : that.username != null) return false;
        if (passwd != null ? !passwd.equals(that.passwd) : that.passwd != null) return false;
        if (schema != null ? !schema.equals(that.schema) : that.schema != null) return false;
        return database != null ? database.equals(that.database) : that.database == null;
    }

    @Override
    public int hashCode() {
        int result = dbType != null ? dbType.hashCode() : 0;
        result = 31 * result + (name != null ? name.hashCode() : 0);
        result = 31 * result + (host != null ? host.hashCode() : 0);
        result = 31 * result + (port != null ? port.hashCode() : 0);
        result = 31 * result + (username != null ? username.hashCode() : 0);
        result = 31 * result + (passwd != null ? passwd.hashCode() : 0);
        result = 31 * result + (database != null ? database.hashCode() : 0);
        result = 31 * result + (schema != null ? schema.hashCode() : 0);
        return result;
    }
}
